﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMS.DAL;
using MMS.Model;

namespace MMS.BLL
{
    public class OrderManager
    {
        private OrderService os = new OrderService();

        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="list">购买的商品集合</param>
        /// <param name="totalMoney">商品总金额</param>
        /// <param name="adminId">员工编号</param>
        /// <returns>如果添加成功返回true，否则返回false</returns>
        public bool CreateOrder(List<BuyGoodsInfo> list, double totalMoney, int adminId)
        {
            //TODO活动:购买满1000元优惠50元
            if (totalMoney >= 1000)
            {
                totalMoney -= 50;//减去优惠的金额
            }
            return os.InsertOrder(list, totalMoney, adminId);
        }
        public List<OrderGoods> GetTop10BuyCountGoods(DateTime start, DateTime end)
        {
            return os.SelectTop10BuyCountGoods(start, end);
        }
        public List<GoodsOrderDetail> GetGoodsOrderDetail(string goodsCode, DateTime start, DateTime end)
        {
            return os.SelectGoodsOrderDetail(goodsCode, start, end);
        }
    }
}
